#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <crypt.h>
#include <syslog.h>
#include <mhash.h>
#include <postgresql/libpq-fe.h>

#define DB_ARQ_CONF "/etc/pam_pg_db.conf"
#define SALT "%.2s"
#define PW_CRYPT 0
#define PW_MD5 1
#define PW_CRYPT_MD5 2
#define PW_CLEAR 3

typedef struct conf_t{
  char * host;
  char * port;
  char * dbname;
  char * user;
  char * password;
} * CONF_DB;

typedef struct pgconn_t {
  PGconn * pgconn;
  CONF_DB conf;
} * CONNECTION_DB;

#define SYSLOG(x...)   openlog("pam-pg", LOG_PID, LOG_AUTH); \
                       syslog(LOG_INFO, ##x);                \
                       closelog();


CONNECTION_DB init_db(char *);
void free_db(CONNECTION_DB);
CONF_DB load_conf(char *);
char * get_next_line(FILE *, char *);
void remove_enter(char *);
